package JDK8新特性;


import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import com.sun.xml.internal.ws.addressing.WsaActionUtil;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class lambda {

    public static void main(String args[]) {

        //多参数无返回
        NOReturnMultiParam noReturnMultiParam = (int a, int b) -> {
            System.out.println("多参数无返回" + a + b);
        };
        noReturnMultiParam.method(6, 6);
        //无参数无返回
        NoReturnNoParam noReturnNoParam = () -> {
            System.out.println("无参数无返回");
        };
        noReturnNoParam.method();
        //一个参数无返回
      NoReturnOneParam noReturnOneParam = (int a) -> {
            System.out.println("一个参数无返回" + a);
        };
        noReturnOneParam.method(6);

        //一个参数有返回值
        ReturnOneParam returnOneParam = a -> a + 3;
        System.out.println(returnOneParam.method(3));
        ArrayList<HashMap> items = new ArrayList<>();
        HashMap hashMap = new HashMap<Integer,String>();
        hashMap.put(1,"zhulei" );
        System.out.println(hashMap);
        //lambda创建线程
        Thread t=new Thread(()->{
            for (int i=0;i<10;i++)
            {
                System.out.println(2+":"+i);
            }
        });
        t.start();







    }


    @FunctionalInterface
    /**
     * 多参数无返回
     */
    public interface NOReturnMultiParam {
        void method(int a, int b);

    }

    /**
     * 无参数无返回
     */
    @FunctionalInterface
    public interface NoReturnNoParam {
        void method();

    }

    /**
     * 一个参数无返回
     */
    @FunctionalInterface
    public interface NoReturnOneParam {
        void method(int a);
    }

    /**
     * 多参数有返回
     */
    @FunctionalInterface
    public interface ReturnMultiParam {
        int method(int a, int b);
    }

    /**
     * 无参数有返回
     */
    @FunctionalInterface
    public interface ReturnNoParam {
        int method();
    }

    /**
     * 一个参数有返回
     */
    @FunctionalInterface
    public interface ReturnOneParam {
        int method(int a);
    }


}
